A computer program comprises code statements designated for execution by software or a processor. Program slicing refers to extracting one or more statements (i.e., a subprogram or a slice) from a program by analyzing the program's data and control flow. Slicing may be used to generate a slice to assist program understanding, debugging, testing, verification, transformation, or other aspect of program development.
A slice comprises a set of statements that are related to or potentially related to the computation of values at certain points in the data flow or control flow in the program that a user desires to analyze (i.e., slicing criteria). Typically, a slice generator generates a slice from a program dependence graph (PDG), which represents data flow and control flow dependences of a program. Statements to include in the slice are identified by backward or forward traversal of the PDG from the slicing criteria.
Unfortunately, existing slicing approaches may generate a slice that includes unnecessary statements, fails to terminate, or is unsuitable for program transformation. Additionally, if a program is unstructured (i.e., describes an arbitrary control flow), such slicing approaches may generate a slice that is incorrect.